package com.runvp.common.hex;


import java.util.LinkedList;
import java.util.List;

/**
 * 解析处理
 */
public class ParseHandle {

    public static void main(String[] args) {
        System.out.println(parseBizBody("3C31001501000410016402000300"));
        System.out.println(parseBizBodyArr("3C0000000C0000000000000100000000000000000000000000020000000000000000000000000003000000000000000000000000000400000000000000000000000000050000000000000000000000000006000000000000000000000000000700000000000000000000000000080000000000000000"));

    }

    /**
     * 处理业务报文
     * @param body  16进制业务报文
     * @return str 十进制报文内容
     */
    public static String parseBizBody(String body){
        StringBuilder parseResult = new StringBuilder();
        String str;
        for (int i = 0; i < body.length()/2; i++) {
            str = body.substring(i*2,i*2+2);
            parseResult.append(HexConvert.hexNumber2Ten(str));
        }
        return parseResult.toString();
    }
    /**
     * 处理业务报文
     * @param body  16进制业务报文
     * @return str 十进制报文内容
     */
    public static List<String> parseBizBodyArr(String body){
        int len = body.length()/2;
        List<String> parseResult = new LinkedList<>();
        String str;
        for (int i = 0; i < len; i++) {
            str = body.substring(i*2,i*2+2);
            parseResult.add(HexConvert.hexNumber2Ten(str));
        }
        return parseResult;
    }
}
